<?php

include '../connectBDD.php';
if (isset($_GET['id_news'])) {
    $id_news = $_GET['id_news'];
    $query = "DELETE FROM news WHERE id_news = '" . $id_news . "'";

    mysql_query($query) or die(mysql_error());

    $result = mysql_query("SELECT id_news, title_news FROM news");
    $nb_res = mysql_num_rows($result);
    echo "<a href=javascript:ouvrirFenetre('creationNews.php')>Créer une nouvelle news</a></div>";
    echo "<div style='color:green'>$nb_res news trouvée(s)</div>";
    if (mysql_num_rows($result) <= 0) {
        echo "<div class='no_result_found'>Aucun news.</div>";
    } else {
        echo "<div class='listNews'>";
        while ($row = mysql_fetch_assoc($result)) {

            echo"
                         <div id='newsAdmin'>
                            " . $row['title_news'] . "
                            <div style='float:right'>
                                <a class='edit_data' href=\"javascript:ouvrirFenetre('creationNews.php?id_news=" . $row['id_news']."')\"><img src='../images/Edit_Yes_32.png' /></a>
                                <a class='croix_ferm' href=\"javascript:supprimerNews('" . $row['id_news'] . "')\"><img src='../images/Close-32.png' height='15px' width='15px'/></a>
                            </div>
                        </div>";
        }
        echo "</div>";
    }
}
?>
